package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.HotelIndent;
import cn.wolfcode.trip.base.domain.UserIntegral;
import cn.wolfcode.trip.base.domain.UserOrder;
import cn.wolfcode.trip.base.mapper.HotelIndentMapper;
import cn.wolfcode.trip.base.mapper.UserIntegralMapper;
import cn.wolfcode.trip.base.mapper.UserOrderMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IUserHotelService;
import cn.wolfcode.trip.base.service.IUserOrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class UserHotelServiceImpl implements IUserHotelService {

    @Autowired
    private HotelIndentMapper hotelIndentMapper;
    @Autowired
    private UserIntegralMapper integralMapper;

    @Override
    public void saveOrUpdate(HotelIndent empty) {

        if(empty.getId() == null){
            hotelIndentMapper.insert(empty);
        }else {
            hotelIndentMapper.updateByPrimaryKey(empty);
        }
    }



    @Override
    public PageInfo<HotelIndent> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<HotelIndent> list = hotelIndentMapper.selectForList(qo);
        return new PageInfo<HotelIndent>(list);
    }

    @Override
    public HotelIndent selectByUUID(String orderNumber) {
        return hotelIndentMapper.selectByUUID(orderNumber);
    }

    @Override
    public PageInfo<HotelIndent> selectByUserId(Long id, QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<HotelIndent> list = hotelIndentMapper.selectByUserId(id,qo);
        return new PageInfo<HotelIndent>(list);
    }

    @Override
    public HotelIndent selectByHotelId(Long id) {
        return hotelIndentMapper.selectByHotelId(id);
    }


}
